package com.z6school.manage.mapper;
import com.baomidou.mybatisplus.core.injector.methods.SelectById;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.z6school.manage.common.pojo.DeptMajorClass;
import com.z6school.manage.common.pojo.Nodes;
import com.z6school.manage.po.Dept;
import com.z6school.manage.po.School;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface DeptMapper extends BaseMapper<Dept> {

    @Select("select c.*,p.name parentName from school c left join school p on c.parentId=p.id")
    List<Map<String,Object>> findObjects();

    @Select("select count(*) from school where id=#{id}")
    int findChildCount(Integer id);

    @Delete("delete from school where id=#{id}")
    int deleteObject(Integer id);

    int insertObject(School school);

    int updateObject(School school);

    School findById(Integer id);

    /***************************************************************/
    @Select("select * from dept")
    List<DeptMajorClass> findAll();

    @Delete("delete from dept where id=#{id}")
    int deleteByDeptId(Integer id);

    @Select("select id,name,parentId from dept")
    List<Nodes> findZTreeNodes();
}
